﻿using QLevelGenerator.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace QLevelGenerator.Controllers
{
    public class HomeController : Controller
    {
        private string[] keySymbols = new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
        private string[] otherSymbols = new[] { "a", "b", "c" };
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult ConvertLevels([ModelBinder(typeof(TwoDimensionalArrayBinder<int>))] int[][] table)
        {
            var converter = new Converter();
            var outputData = converter.ConvertMatrixToSymbols(table,
                keySymbols,
                otherSymbols);

            return Json(new { data = outputData });
        }
    }
}
